package com.lsmw.ucenter.controller;

import com.alibaba.nacos.api.annotation.NacosInjected;
import com.lsmw.commonutils.R;
import com.lsmw.ucenter.client.MyOssClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/*
 *ClassName:EduOssTransfer
 *UserName:二号男嘉宾
 *CreateTime:2021/1/5 11:24
 */
@RestController
@RequestMapping("/uCenter/edu-oss")
public class UCenterOssTransferController {

    private MyOssClient ossClient;


    @NacosInjected
    public UCenterOssTransferController(MyOssClient ossClient) {
        this.ossClient = ossClient;
    }

    @PostMapping
    public R uploadImg(MultipartFile file) {
//        if (ossClient.uploadFile(file).getCode() == 20000) {
//            throw new XXException(12345, "出错了");
//        }
        System.out.println(ossClient);
        return ossClient.uploadFile(file);
    }

}
